//
//  MyOrderTableViewCell.swift
//  DriverSchoolAPP
//
//  Created by Logel on 2017/5/11.
//  Copyright © 2017年 Logel. All rights reserved.
//

import UIKit

class MyOrderTableViewCell: UITableViewCell {
    @IBOutlet weak var okBtn: UIButton!

    @IBOutlet weak var orderNameLbl: UILabel!
    @IBOutlet weak var priceLbl: UILabel!
    @IBOutlet weak var timeLbl: UILabel!
    @IBOutlet weak var orderStatusLbl: UILabel!
    
    var selectNum:Int!
    var delegate:MyOrderTableViewCellBtnClickDelegate!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        okBtn.layer.cornerRadius = 5
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    var mo:MyOrder!{
        didSet{
            priceLbl.text = "￥ \(mo.payAmount)"
            timeLbl.text = mo.createTime
            switch mo.payStatus {
            case "1":
                orderStatusLbl.text = "已支付"
                okBtn.isEnabled = false
                okBtn.setTitle("已付款", for: .normal)
                okBtn.backgroundColor = UIColor.lightGray
            default:
                orderStatusLbl.text = "未支付"
                okBtn.isEnabled = true
                okBtn.setTitle("点击付款", for: .normal)
                okBtn.backgroundColor = KP_MAIN_BLUE
            }
            
            switch mo.orderType {
            case "1":
                orderNameLbl.text = "全包"
            case "2":
                orderNameLbl.text = "课时（报名)"
            case "3":
                orderNameLbl.text = "分期（报名）"
            case "4":
                orderNameLbl.text = "预报名（报名）"
            case "5":
                orderNameLbl.text = "分期（科目一）"
            case "6":
                orderNameLbl.text = "分期（科目二）"
            case "7":
                orderNameLbl.text = "预报名（科目一前）"
            case "8":
                orderNameLbl.text = "预报名（科目一）"
            case "9":
                orderNameLbl.text = "预报名（科目二）"
            default:
                orderNameLbl.text = "单课时"
            }
            
        }
    }

    @IBAction func doPay(_ sender: UIButton) {
        delegate.payBtnClick(indexpath: selectNum)
    }
   
}

protocol MyOrderTableViewCellBtnClickDelegate {
    func payBtnClick(indexpath:Int)
}
